<!DOCTYPE html>
<html>
<head>
    <title>平涛</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">

    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/weui.min.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/jquery-weui.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/style.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/aui-iconfont.css">

    <style type="text/css">
        .b-t{border-bottom: 1px solid #d9d9d9;padding-top: 10px;}
        .weui_cells{margin-top: -1px !important}
        .cl1{width:80px;height: 20px;background: #eee !important;padding: 5px;margin: 2px;text-align: center; }
        .c-input1{width: 11% !important;border: 1px solid #ccc}
        .weui_navbar+.weui_tab_bd{padding-top: 47px !important}
        .c-r1{color: red !important}
        .weui_btn{font-size: 14px !important;width: 150px;margin-left:-18px;color:#9E9E9E}
        /*.weui_btn+.weui_btn{margin-top: 5px}*/
        .weui_btn_plain_default{border: none;line-height: 1.5}
        .f-s11{font-size: 12px}
    </style>
</head>


<body ontouchstart>

<!-- <form action="{:U('Client/addCheck',array('id'=>$id))}" method="post">  -->
<form>
    <div class="weui_tab">
        <div class="weui_navbar weui_navbar1">
            <div class="weui_navbar_item weui_bar_item_on">
                <div style="text-align:left;float:left">
                    <if condition="$id eq ''">
                        <a class="c-r1" href='javascript:history.go(-1)'>取消</a>
                    <else />
                        <a class="c-r1" href="{:U('Client/del',array('id'=>$id))}">取消</a>
                    </if>
                </div>
                <span>新增客户</span>
                <div class="f-r">
                    <span class="f-s1" style="cursor:pointer;color:green;" onclick="zjtj()">添加</span>
                    <!-- <button type="submit" class="f-s1 c-r1">完成</button> -->
                </div>
            </div>
        </div>
        <div class="weui_tab_bd">
            <div class="weui_cells weui_cells_form">
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label class="weui_label">客户名称</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" name="client_name" id="client_name" value="{$clientArr.client_name}" placeholder="请输入客户名称">
                    </div>
                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">店长</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" name="shop_manager" id="shop_manager" value="{$clientArr.shop_manager}" placeholder="请输入店长姓名">
                    </div>
                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">店庆时间</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" name="shop_birthday" id="shop_birthday" value="{$clientArr.shop_birthday}" placeholder="请输入店庆时间">
                    </div>
                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label class="weui_label">负责人</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <!-- <a href="{:U('Client/contactAdd')}" class="weui_btn weui_btn_plain_default" style="float: left;">请输入负责人信息</a> -->
                        <!-- <a href="{:U('Client/contactAdd')}">
                            <span class="weui_tabbar_label aui-iconfont aui-icon-add" style="float: left;line-height: 1"></span>
                        </a> -->
                        <volist name="contactList" id="val" empty="暂无">
                            <a href="{:U('Client/contactDetail',array('id'=>$val['id']))}" class="weui_btn weui_btn_default">{$val.realname}</a>
                        </volist>
                        <span style="color:blue;cursor:pointer;" id="add-fzr" onclick="tjfzr()">添加负责人</span>
                    </div>
                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label class="weui_label">拜访次数</label></div>
                    <div class="weui_cell_bd weui_cell_primary f-s11">
                        <input class="weui_input c-input1" type="text" name="visit_year_num" value="{$clientArr.visit_year_num}" > 次/年
                        <input class="weui_input c-input1" type="text" name="visit_quarter_num" value="{$clientArr.visit_quarter_num}" > 次/季度
                        <input class="weui_input c-input1" type="text" name="visit_month_num" value="{$clientArr.visit_month_num}" > 次/月
                    </div>
                </div>
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">备注</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" name="remark" value="{$clientArr.remark}" placeholder="请输入备注">
                    </div>
                </div>
            </div>
            <div class="weui_cells_title">联系方式</div>
            <div class="weui_cells weui_cells_form">
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">地址</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" name="location" id="location" value="{$clientArr.location}" placeholder="请输入地址">
                        <input type="hidden" name="longitude" value="{$clientArr.longitude}" >
                        <input type="hidden" name="latitude" value="{$clientArr.latitude}" >
                    </div>
                </div> 
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">联系方式</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" name="tel" id="tel" value="{$clientArr.tel}" placeholder="请输入联系方式">
                    </div>
                </div> 
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">QQ</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" name="qq" id="qq" value="{$clientArr.qq}" placeholder="请输入QQ号">
                    </div>
                </div> 
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">微信</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" name="wechat" id="wechat" value="{$clientArr.wechat}" placeholder="请输入微信号">
                    </div>
                </div> 
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">Email</label></div>
                    <div class="weui_cell_bd weui_cell_primary">
                        <input class="weui_input" type="text" name="email" id="email" value="{$clientArr.email}" placeholder="请输入Email号">
                    </div>
                </div> 
            </div>
        </div>

        <include file="Index/footer" />
    
    </div>
</from>

    <script type="text/javascript" src="__PUBLIC__/Wechat/js/jquery-2.1.4.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Wechat/js/fastclick.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Wechat/js/jquery-weui.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Wechat/layer_mobile/layer.js"></script> 
    <script>
        $(function() {
            FastClick.attach(document.body);
        });


        // 添加客户
        function zjtj(){
            if( $.trim($('#client_name').val()) == '' ){ 
                layer.open({
                    content: '请先填写客户名称',
                    skin: 'msg',
                    time: 1 ,
                });
            }else{
                $.ajax({  
                    url: "{:U('Client/addCheck',array('id'=>$id))}",   // 如果$id为真，则表示修改此条客户
                    type: "POST",  
                    data: $('form').serializeArray(), 
                    success: function(msg){  
                        console.log(msg);
                        layer.open({
                            content: msg['content'],
                            skin: 'msg',
                            time: 1 ,
                        });
                        if(msg['state'] == 200){
                            setTimeout('window.location.href = "{:U('Client/index')}"', 1000);
                        }
                    }  
                });
            }
            
        }

        // 添加负责人  
        function tjfzr(){
            if( $.trim($('#client_name').val()) == '' ){ 
                layer.open({
                    content: '请先填写客户名称',
                    skin: 'msg',
                    time: 1 ,
                });
            }else{
                $('#add-fzr').attr('onclick','');
                $.ajax({  
                    url: "{:U('Client/addCheck',array('id'=>$id))}", 
                    type: "POST",  
                    data: $('form').serializeArray(), 
                    success: function(msg){ 
                        console.log(msg);
                        if(msg['state'] == 200){
                            var url = "{:U('Client/contactAdd',array('cid'=>'clientid'))}";
                            url = url.replace('clientid',msg['id']);
                            window.location.href = url;
                        }
                    }  
                });
            }
            
        }

    
    </script>

</body>
</html>
